#!/usr/bin/env python
#    prop_nolondon_soppacc
#    ---------------------
#    Molecule:         H2O
#    Wave Function:    CCSD (SOPPA(CCSD))
#    Test Purpose:     Calculation of SOPPA(CCSD) no-London shielding constants
#                      through ABACUS

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from runtest_dalton import Filter, TestRun

test = TestRun(__file__, sys.argv)

f = Filter()

f.add(from_string = 'Atoms and basis sets',
      num_lines = 13,
      rel_tolerance = 1.0e-2)

f.add(from_string = 'Cartesian Coordinates',
      num_lines = 9,
      rel_tolerance = 1.0e-8)

f.add(string = 'Number of coordinates in each symmetry',
      rel_tolerance = 1.0e-2)
      
f.add(string = 'Number of orbitals in each symmetry',
      rel_tolerance = 1.0e-2)



# Energies
f.add(from_string = 'SUMMARY OF COUPLED CLUSTER CALCULATION',
      to_string = 'END OF COUPLED CLUSTER CALCULATION',
      rel_tolerance = 1.0e-9)


f.add(re = 'SOPPA\(CCSD\) \: * Second Order Polarization Propagator Approximation',
      rel_tolerance = 1.0e-2)
f.add(string = 'Nuclear magnetic shieldings',
      rel_tolerance = 1.0e-2)
f.add(string = 'Magnetic susceptibilities',
      rel_tolerance = 1.0e-2)
f.add(string = 'London orbitals are NOT used',
      rel_tolerance = 1.0e-2)
f.add(string = 'Molecular rotational g-factor',
      rel_tolerance = 1.0e-2)

f.add(from_string = 'Magnetizabilities',
      num_lines = 9,
      mask = [2],
      abs_tolerance = 1.0e-3)

f.add(from_string = 'Total magnetizability tensor',
      num_lines = 9,
      abs_tolerance = 1.0e-6)

f.add(from_string = 'Diamagnetic magnetizability tensor',
      num_lines = 9,
      abs_tolerance = 1.0e-6)

# Molecular rotational g-factor
f.add(from_string = 'Molecular rotational g-tensor',
      num_lines = 10,
      abs_tolerance = 1.0e-6)

# Molecular rotational g-factor in principal axis system 
f.add(from_string = 'Molecular rotational g-tensor in principal axis system',
      num_lines = 7,
      abs_tolerance = 1.0e-6)

# Shielding tensors (symmetry coordinates) 
f.add(from_string = 'Shielding tensors in symmetry coordinates',
      num_lines = 24,
      abs_tolerance = 1.0e-3)

# Chemical shielding for ...
f.add(from_string = 'Chemical shielding for ',
      num_lines = 16,
      abs_tolerance = 1.0e-3)

# Total shielding tensor for ...
f.add(from_string = 'Total shielding tensor',
      num_lines = 11,
      abs_tolerance = 1.0e-3)

# Diamagnetic and paramagnetic contributions
f.add(string = 'Diamagnetic contribution:',
      abs_tolerance = 1.0e-3)

# Chemical shieldings
f.add(from_re = 'Summary of chemical shieldings',
      num_lines = 14,
      abs_tolerance = 1.0e-3)

test.run(['prop_nolondon_soppacc.dal'], ['H2O_intgrl_sym.mol'], f={'out': f},
         accepted_errors=['not implemented for parallel calculations.'])

sys.exit(test.return_code)
